<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计算属性</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <p>{{ message.split('').reverse().join('') }}</p>
        <p>{{ reverseMessage }}</p>
        <p>{{ watchMessage }}</p>
    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                message: 'Hello World',
                watchMessage: ''
            },
            computed: {
                reverseMessage() {
                    return this.message.split('').reverse().join('')
                }
            },
            watch: {
                message() {
                    this.watchMessage = this.message.split('').reverse().join('')
                }
            },
            beforeCreate() {
                console.log(this.message)
            },
            created() {
                console.log(this.message)
            }
        })
    </script>
</body>
</html>